package router

import (
	"fmt"
	"git.mycaigou.com/gfyx/micro-gfyx-mp-api/http_server/controller"
	"git.mycaigou.com/gfyx/micro-gfyx-mp-api/http_server/controller/business_opportunity"
	"git.mycaigou.com/gfyx/micro-gfyx-mp-api/http_server/controller/clue"
	"git.mycaigou.com/gfyx/micro-gfyx-mp-api/http_server/controller/common"
	"git.mycaigou.com/gfyx/micro-gfyx-mp-api/http_server/controller/message"
	"git.mycaigou.com/gfyx/micro-gfyx-mp-api/http_server/controller/subscription"
	"git.mycaigou.com/gfyx/micro-gfyx-mp-api/http_server/controller/user"
	"git.mycaigou.com/gfyx/micro-gfyx-mp-api/infrastructure/di"
	"github.com/gin-gonic/gin"
)

// RegisterHealthRouters 检测
func RegisterHealthRouters(g *gin.RouterGroup) {
	new(controller.HealthController).RegisterRouter(g)
}

func MpUserRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		mpController *common.MpController,
	) {
		mpController.RegisterRouter(g)

	})

	fmt.Printf("MpUserRegisterRouters err: %+v\n", err)
}

func MiniProgramRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		miniProgramController *common.MpController,
	) {
		miniProgramController.RegisterMiniProgramRouter(g)
	})

	fmt.Printf("MiniProgramRegisterRouters err: %+v\n", err)
}

func OpenRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		openController *common.OpenController,
	) {
		openController.RegisterRouter(g)
	})

	fmt.Printf("OpenRegisterRouters err: %+v\n", err)
}

func UserRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		userController *user.UserController,
	) {
		userController.RegisterRouter(g)

	})

	fmt.Printf("UserRegisterRouters err: %+v\n", err)
}

func SyncUserRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		syncUserController *user.SyncUserController,
	) {
		syncUserController.RegisterRouter(g)

	})

	fmt.Printf("SyncUserRegisterRouters err: %+v\n", err)
}

// 公用模块路由注册
func CommonRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		commonController *common.CommonController,
		fileController *common.FileController,
	) {
		commonController.RegisterRouter(g)
		fileController.RegisterRouter(g)
	})

	fmt.Printf("CommonRegisterRouters err: %+v\n", err)
}

func CustomerRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		customerController *clue.CustomerController,
	) {
		customerController.RegisterRouterOld(g)

	})

	fmt.Printf("CustomerRegisterRouters err: %+v\n", err)
}

func SubscriptionRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		opSubscriptionController *subscription.SubscriptionController,
	) {
		opSubscriptionController.RegisterRouter(g)
	})

	fmt.Printf("SubscriptionRegisterRouters err: %+v\n", err)
}

func ReportRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		reportController *clue.ReportController,
	) {
		reportController.RegisterRouter(g)
	})

	fmt.Printf("ReportRegisterRouters err: %+v\n", err)
}

func AnonymityRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		anonymityController *clue.AnonymityController,
	) {
		anonymityController.RegisterRouter(g)
	})

	fmt.Printf("ReportRegisterRouters err: %+v\n", err)
}

func SupplierRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		supplierController *business_opportunity.SupplierController,
	) {
		supplierController.RegisterRouter(g)
	})

	fmt.Printf("SupplierRegisterRouters err: %+v\n", err)
}

func ContactRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		contactController *business_opportunity.ContactController,
	) {
		contactController.RegisterRouter(g)
	})

	fmt.Printf("ContactRegisterRouters err: %+v\n", err)
}

func OptionRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		optionController *common.OptionController,
	) {
		optionController.RegisterRouter(g)
	})

	fmt.Printf("OptionRegisterRouters err: %+v\n", err)
}

func VerifyRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		verifyCodeController *message.VerifyCodeController,
	) {
		verifyCodeController.RegisterRouter(g)
	})

	fmt.Printf("VerifyRegisterRouters err: %+v\n", err)
}

func BusinessOpportunityRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(
		customerCtl *business_opportunity.CustomerController,
		bidCtl *business_opportunity.BidController,
		projectCtl *business_opportunity.ProjectController,
		buildingCtl *business_opportunity.BuildingController,
		landCtl *business_opportunity.LandController,
	) {
		customerCtl.RegisterRouter(g)
		bidCtl.RegisterRouter(g)
		projectCtl.RegisterRouter(g)
		buildingCtl.RegisterRouter(g)
		landCtl.RegisterRouter(g)
	})

	fmt.Printf("BusinessOpportunityRegisterRouters err: %+v\n", err)
}

func ClueManageRegisterRouters(g *gin.RouterGroup) {
	c := di.InjectInstance()
	err := c.Invoke(func(c *clue.ClueManageController) {
		c.RegisterRouter(g)
	})
	fmt.Printf("ClueManageRegisterRouters err: %+v\n", err)
}
